package com.hitales.ma.medicalrecord.config;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.PropertyWriter;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;

public class GlobalCustomPropertyFilter extends SimpleBeanPropertyFilter {

    @Override
    public void serializeAsField(Object pojo, JsonGenerator gen, SerializerProvider provider, PropertyWriter writer) throws Exception {
        if ("message".equals(writer.getName())) {
            gen.writeStringField("message", "过滤器修改_" + writer.getMember().getValue(pojo));
        } else {
            writer.serializeAsField(pojo, gen, provider);
        }
    }
}
